export function md5(str: string) {
    var md = java.security.MessageDigest.getInstance("MD5");// 生成一个MD5加密计算摘要
    md.update(java.lang.String(str).getBytes("UTF-8"));// 计算md5函数，字符编码是 UTF-8
    return byteArrayToHexString(md.digest());
}


export function byteArrayToHexString(bytes: any[]) {
    var val = "";
    for (var i = 0; i < bytes.length; i++) {
        var tmp = bytes[i];
        if (tmp < 0) {
            tmp = 256 + tmp;
        }
        tmp = tmp.toString(16);
        if ((tmp + "").length == 1) {
            tmp = "0" + tmp;
        }
        val += tmp;
    }
    return val;
}
